package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	comment := "Hello, World!"
	basicReader := strings.NewReader(comment)
	fmt.Printf("字符串长度: %d\n", basicReader.Size())
	reader := bufio.NewReader(basicReader)
	fmt.Println("缓冲区长度：", reader.Size())
	// 此时缓冲区还没有被填充
	fmt.Println("缓冲区里的未读字节数：", reader.Buffered())
	
	bytes, err := reader.Peek(5)
	if err != nil {
		fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
	}
	fmt.Printf("Peek读取(%d): %q\n", len(bytes), bytes)
	fmt.Println("缓冲区里的未读字节数：", reader.Buffered())
}
